﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using fu = functionService;
using h = functionService.shorts;
using da = functionService.DATECOD;

namespace ETALON
{
    namespace ENUMS
    {
        enum keys { 
                    b1_0, b1_01, b1_02, b1_03, b1_04, b1_05, b1_06, b1_07, b1_08, b1_09, b1_00,  b1_11, b1_12, b1_13back,
                    b2_0, b2_01, b2_02, b2_03, b2_04, b2_05, b2_06, b2_07, b2_08, b2_09, b2_00, b2_11, b2_12, b2_13del,
                    b3_0, b3_01, b3_02, b3_03, b3_04, b3_05, b3_06, b3_07, b3_08, b3_09, b3_00, b3_11, b3_12Enter,
                    b4_0, b4_01, b4_02, b4_03, b4_04, b4_05, b4_06, b4_07, b4_08, b4_09, b4_00, b4_11, b4_12, b4_13Exit,
                    b5_0, b5_01, b5_02, b5_03, b5_04, b5_05, b5_06, b5_07, b5_08, b5_09, b5_00End, 
                    b888_noEnyKey
                  }
        enum PLP_FormGridSelect
        {
            zagolovok_1=1,
            array_Caption_Columns_2=2,
            array_FormatString_3=3,
            array_DataGridViewContentAlignment_4=4,// array int
            size_font_in_GRID_find_5,
            names_control_6=6, visible_controls_7=7
        }
    }
    namespace mode
    {
        enum keym { Rus, RusBig, Eng, EngBig }
        enum press { CTRL, CTRL_ALT, ALT, ALT_SHIFT, SHIFT, Enter, KeyLeft, KeyRight, DEL, HOME, END, other }
    }
    public partial class FormGridSelect : Form
    {
        functionService.prm_city q;
        functionService.prm_FormGridSelect qg;
        public bool IsOK;

        ENUMS.keys keyCurrent; 

        mode.keym curMode;mode.press pressCurrent; string txt; bool IsPressShift;
        public bool IsEnter;
        public string valueEnter;
        public int currentPositionCursor;
        DataTable dt;

        public FormGridSelect()
        {
            InitializeComponent(); InitializeComponentKey();
        }
        public void InitializeComponentKey()
        {
            curMode = mode.keym.Rus; txt = ""; IsPressShift = false; IsEnter = false; valueEnter = "";
        }

        #region ini
        public FormGridSelect(DataTable dto )
            : this()
        {
            //DataGridViewContentAlignment[] daaa;
            //string[] sCaption;
            
            InitializeComponentMy(dto); readControl2();
        }
        public FormGridSelect(DataTable dto, int[] iwidth, string[] sCaption, DataGridViewContentAlignment[] daaa) : this()
        {
            InitializeComponentMy(dto, iwidth, sCaption,daaa);
        }
        public FormGridSelect(DataTable dto, int[] iwidth, string[] sCaption, DataGridViewContentAlignment[] daaa, string[] aFormatCELL)
            : this()
        {
            InitializeComponentMy(dto, iwidth, sCaption, daaa, aFormatCELL);
        }
        DataGridViewContentAlignment[] convertIntArrayToDataGridViewContentAlignmentArray(int[] ai)
        {
            DataGridViewContentAlignment[] da = new DataGridViewContentAlignment[ai.Length];
            for (int i = 0; i < ai.Length; i++)
            {
                da[i] = (DataGridViewContentAlignment)ai[i];
            }
            return da;
        }
        string  set_aFormatCELLo(string s1s2s3)
        {
            string s = "";
            if (s1s2s3 == "C0")
            {
                s = "C0";
            }
            else if (s1s2s3 == "N")
            {
                s = "N";
            }
            else { s = "N"; }
            return s;
        }
        void transformFormatCELL(string[] aFormatCELLo)
        {
            int ic = aFormatCELLo.Length;
            for (int j = 0; j < ic; j++)
            {
               aFormatCELLo[j]= set_aFormatCELLo(aFormatCELLo[j]);
            }
            dataGridView1.Columns[1].DefaultCellStyle.Format = "C0";
        }
        void InitializeComponentMy(DataTable dto)
        {
            //, int[] iwidth, string[] sCaption, DataGridViewContentAlignment[] daaa, string[] aFormatCELL
            
            IsOK = false;
            qg = new functionService.prm_FormGridSelect("PLP_FormGridSelect"); dt = dto;
            string[] sCaption = qg.tk_array_string(ETALON.ENUMS.PLP_FormGridSelect.array_Caption_Columns_2);
            int[] iDataGridViewContentAlignment = qg.tk_array_int(ETALON.ENUMS.PLP_FormGridSelect.array_DataGridViewContentAlignment_4);
            DataGridViewContentAlignment[] daaa = convertIntArrayToDataGridViewContentAlignmentArray(iDataGridViewContentAlignment);
            string[] aFormatCELL = qg.tk_array_string(ETALON.ENUMS.PLP_FormGridSelect.array_FormatString_3);
            
            dataGridView1.DataSource = dto;
            setColumnsCaptionFormatCELL(sCaption, daaa, aFormatCELL);
           // dataGridView1.DefaultCellStyle.Font = new Font("Courier New", q.tk_int(param.size_font_in_GRID_find_32));
            dataGridView1.DefaultCellStyle.Font = new Font("Courier New", qg.tk_int(ETALON.ENUMS.PLP_FormGridSelect.size_font_in_GRID_find_5));
           // transformFormatCELL(aFormatCELL);
        }
        DataGridViewContentAlignment ALGMENTGRID(int iDataGridViewContentAlignment)
        {
            DataGridViewContentAlignment currentA = (DataGridViewContentAlignment)iDataGridViewContentAlignment;
            //if (iDataGridViewContentAlignment == 1)
            //{ currentA = DataGridViewContentAlignment.MiddleLeft ; }
            //else if (iDataGridViewContentAlignment == 2)
            //{ currentA = DataGridViewContentAlignment.MiddleCenter; }
            //else if (iDataGridViewContentAlignment == 3)
            //{ currentA = DataGridViewContentAlignment.MiddleRight; }
            //else if (iDataGridViewContentAlignment == 4)
            //{ currentA = DataGridViewContentAlignment.TopLeft; }
            //else if (iDataGridViewContentAlignment == 5)
            //{ currentA = DataGridViewContentAlignment.TopCenter; }
            //else if (iDataGridViewContentAlignment == 6)
            //{ currentA = DataGridViewContentAlignment.TopRight; }
            //else if (iDataGridViewContentAlignment == 7)
            //{ currentA = DataGridViewContentAlignment.BottomLeft; }
            //else if (iDataGridViewContentAlignment == 8)
            //{ currentA = DataGridViewContentAlignment.BottomCenter; }
            //else if (iDataGridViewContentAlignment == 9)
            //{ currentA = DataGridViewContentAlignment.BottomRight; }
            //else if (iDataGridViewContentAlignment == 10)
            //{ currentA = DataGridViewContentAlignment.NotSet; }
          
            return currentA;
        }
        void InitializeComponentMy(DataTable dto, int[] iwidth, string[] sCaption, DataGridViewContentAlignment[] daaa, string[] aFormatCELL)
        {
            IsOK = false;
            q = new functionService.prm_city(); dt = dto;
            dataGridView1.DataSource = dto;
            setColumnsWidthAndCaption(iwidth, sCaption, daaa, aFormatCELL);
            dataGridView1.DefaultCellStyle.Font = new Font("Courier New", qg.tk_int(ETALON.ENUMS.PLP_FormGridSelect.size_font_in_GRID_find_5));
        }
        void InitializeComponentMy(DataTable dto, int[] iwidth, string[] sCaption, DataGridViewContentAlignment[] daaa)
        {
            IsOK = false;
            q = new functionService.prm_city(); dt = dto;
            dataGridView1.DataSource = dto;
            setColumnsWidthAndCaption(iwidth, sCaption,daaa );
            dataGridView1.DefaultCellStyle.Font = new Font("Courier New", qg.tk_int(ETALON.ENUMS.PLP_FormGridSelect.size_font_in_GRID_find_5));
        }
        void setColumnsWidthAndCaption(int[] icw, string[] scc, DataGridViewContentAlignment[] daaa, string[] aFormatCELLo)
        {
            for (int j = 0; j < icw.Length; j++)
            {
                dataGridView1.Columns[j].Width = icw[j]; dataGridView1.Columns[j].HeaderText = scc[j];
                dataGridView1.Columns[j].DefaultCellStyle.Alignment = daaa[j]; //h.m(daaa[j].ToString());
                //dataGridView1.Columns[j].DefaultCellStyle.Format = aFormatCELLo[j];
                //h.m(aFormatCELLo[j]);
            }
           
        }
        string MNY(string ss) 
        { 
            string s = "N"; 
            if (Convert.ToInt32( ss) == 1) { s = "C0"; }
            return s;
        }
        void setColumnsCaptionFormatCELL(string[] scc, DataGridViewContentAlignment[] daaa, string[] aFormatCELLo)
        {
            for (int j = 0; j < scc.Length; j++)
            {
                dataGridView1.Columns[j].HeaderText = scc[j];
                dataGridView1.Columns[j].DefaultCellStyle.Alignment = daaa[j]; //h.m(daaa[j].ToString());
                dataGridView1.Columns[j].DefaultCellStyle.Format = MNY(aFormatCELLo[j]); //h.m(MNY(aFormatCELLo[j]));
            }
           // dataGridView1.Columns[1].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
        }
        void setColumnsWidthAndCaption(int[] icw, string[] scc, DataGridViewContentAlignment[] daaa)
        {
            for (int j = 0; j < icw.Length; j++)
            {
                dataGridView1.Columns[j].Width = icw[j]; dataGridView1.Columns[j].HeaderText = scc[j];
                dataGridView1.Columns[j].DefaultCellStyle.Alignment = daaa[j];
            }
            //dataGridView1.Columns[0].DefaultCellStyle.Format = "";
            //dataGridView1.Columns[1].DefaultCellStyle.Format = "F2";
            //dataGridView1.Columns[2].DefaultCellStyle.Format = "C0";
        }
        #endregion
        private void refreshGridWithFilter( string sfilter)
        {
            DataView v = new DataView(dt); v.RowFilter = string.Concat("name like '%", sfilter, "%'");
            dataGridView1.DataSource = v;
        }
        private void putTxt(string txto)
        {
            string s1 = "", s2 = "", s3 = "";
            if (currentPositionCursor == 0 || currentPositionCursor == txt.Length)
            {
                toolStripTextBox1.Text = string.Concat(txt, txto); txt = toolStripTextBox1.Text;  pressCurrent = mode.press.other;
            }
            else
            {
                s1 = leftText(txt, currentPositionCursor); s2 = txto; s3 = rightText(txt, currentPositionCursor);
                toolStripTextBox1.Text = string.Concat(
                    s1,
                    s2,
                    s3);
                txt = toolStripTextBox1.Text;  pressCurrent = mode.press.other;
            }
            currentPositionCursor++;
            refreshGridWithFilter(txt);
        }
        private string leftText(string stxt, int icc)
        {
            int l = stxt.Length; string stxtLeft = stxt.Substring(0, icc); return stxtLeft;
        }
        private string rightText(string stxt, int icc)
        {
            int l = stxt.Length; string stxtRight = stxt.Substring(icc, l - icc); return stxtRight;
        }
        private void backTxt()
        {
            string txto = toolStripTextBox1.Text; int l = txto.Length; string s1, s2, s3;
            if (l > 0 && currentPositionCursor == l)
            {
                txt = txto.Substring(0, l - 1);
                toolStripTextBox1.Text = txt; 

            }
            else if (currentPositionCursor < l && currentPositionCursor > 0)
            {
                s1 = leftText(txto, currentPositionCursor); s3 = rightText(txto, currentPositionCursor);
                s2 = s1.Substring(0, s1.Length - 1); txt = string.Concat(s2, s3);

            }
            currentPositionCursor--;
            toolStripTextBox1.Text = txt; refreshGridWithFilter(txt);
            pressCurrent = mode.press.other; 
        }
        public string VALUEKEY
        {
            get { return toolStripTextBox1.Text; }
        }

        private string b00
        {
            get
            {
                string s = "ё";
                if (curMode == mode.keym.RusBig) { s = "Ё"; }
                else if (curMode == mode.keym.Eng) { s = "`"; }
                else if (curMode == mode.keym.EngBig) { s = "~"; }
                return s;
            }
        }
        private string b1
        {
            get
            {
                string s = "1";
                if (curMode == mode.keym.RusBig || curMode == mode.keym.EngBig) { s = "!"; } return s;
            }
        }
        private string b2
        {
            get
            {
                string s = "2";
                if (curMode == mode.keym.RusBig || curMode == mode.keym.EngBig) { s = "@"; } return s;
            }
        }
        private string b3
        {
            get
            {
                string s = "3";
                if (curMode == mode.keym.RusBig)
                { s = "№"; }
                else if (curMode == mode.keym.EngBig) { s = "#"; }
                return s;
            }
        }
        private string b4
        {
            get
            {
                string s = "4";
                if (curMode == mode.keym.RusBig) { s = ";"; }
                else if (curMode == mode.keym.EngBig) { s = "$"; }
                return s;
            }
        }
        private string b5
        {
            get
            {
                string s = "5";
                if (curMode == mode.keym.RusBig || curMode == mode.keym.EngBig) { s = "%"; } return s;
                return s;
            }
        }
        private string b6
        {
            get
            {
                string s = "6";
                if (curMode == mode.keym.RusBig) { s = ";"; }
                else if (curMode == mode.keym.EngBig) { s = "$"; }
                return s;
            }
        }
        private string b7
        {
            get
            {
                string s = "7";
                if (curMode == mode.keym.RusBig) { s = "?"; }
                else if (curMode == mode.keym.EngBig) { s = "&"; } return s;
            }
        }
        private string b8
        {
            get
            {
                string s = "8";
                if (curMode == mode.keym.RusBig || curMode == mode.keym.EngBig) { s = "*"; } return s;
            }
        }
        private string b9
        {
            get
            {
                string s = "9";
                if (curMode == mode.keym.RusBig || curMode == mode.keym.EngBig) { s = "("; } return s;
            }
        }
        private string b0
        {
            get
            {
                string s = "0";
                if (curMode == mode.keym.RusBig || curMode == mode.keym.EngBig) { s = ")"; } return s;
            }
        }
        private string b10
        {
            get
            {
                string s = "-";
                if (curMode == mode.keym.RusBig || curMode == mode.keym.EngBig) { s = "_"; } return s;
            }
        }
        private string b11
        {
            get
            {
                string s = "=";
                if (curMode == mode.keym.RusBig || curMode == mode.keym.EngBig) { s = "+"; } return s;
            }
        }

        //====================второй ряд клавиатуры

        private string b111
        {
            get
            {
                string s = "\\";
                return s;
            }
        }
        private string b1b
        {
            get
            {
                string s = "й";
                if (curMode == mode.keym.RusBig) { s = "Й"; }
                else if (curMode == mode.keym.Eng) { s = "q"; }
                else if (curMode == mode.keym.EngBig) { s = "Q"; }
                return s;
            }
        }
        private string b2b
        {
            get
            {
                string s = "ц";
                if (curMode == mode.keym.RusBig) { s = "Ц"; }
                else if (curMode == mode.keym.Eng) { s = "w"; }
                else if (curMode == mode.keym.EngBig) { s = "W"; }
                return s;
            }
        }
        private string b3b
        {
            get
            {
                string s = "у";
                if (curMode == mode.keym.RusBig) { s = "У"; }
                else if (curMode == mode.keym.Eng) { s = "e"; }
                else if (curMode == mode.keym.EngBig) { s = "E"; }
                return s;
            }
        }
        private string b4b
        {
            get
            {
                string s = "к";
                if (curMode == mode.keym.RusBig) { s = "К"; }
                else if (curMode == mode.keym.Eng) { s = "r"; }
                else if (curMode == mode.keym.EngBig) { s = "R"; }
                return s;
            }
        }
        private string b5b
        {
            get
            {
                string s = "е";
                if (curMode == mode.keym.RusBig) { s = "Е"; }
                else if (curMode == mode.keym.Eng) { s = "t"; }
                else if (curMode == mode.keym.EngBig) { s = "T"; }
                return s;
            }
        }
        private string b6b
        {
            get
            {
                string s = "н";
                if (curMode == mode.keym.RusBig) { s = "Н"; }
                else if (curMode == mode.keym.Eng) { s = "y"; }
                else if (curMode == mode.keym.EngBig) { s = "Y"; }
                return s;
            }
        }
        private string b7b
        {
            get
            {
                string s = "г";
                if (curMode == mode.keym.RusBig) { s = "Г"; }
                else if (curMode == mode.keym.Eng) { s = "u"; }
                else if (curMode == mode.keym.EngBig) { s = "U"; }
                return s;
            }
        }
        private string b8b
        {
            get
            {
                string s = "ш";
                if (curMode == mode.keym.RusBig) { s = "Ш"; }
                else if (curMode == mode.keym.Eng) { s = "i"; }
                else if (curMode == mode.keym.EngBig) { s = "I"; }
                return s;
            }
        }
        private string b9b
        {
            get
            {
                string s = "щ";
                if (curMode == mode.keym.RusBig) { s = "Щ"; }
                else if (curMode == mode.keym.Eng) { s = "o"; }
                else if (curMode == mode.keym.EngBig) { s = "O"; }
                return s;
            }
        }
        private string b10b
        {
            get
            {
                string s = "з";
                if (curMode == mode.keym.RusBig) { s = "З"; }
                else if (curMode == mode.keym.Eng) { s = "p"; }
                else if (curMode == mode.keym.EngBig) { s = "P"; }
                return s;
            }
        }
        private string b11b
        {
            get
            {
                string s = "х";
                if (curMode == mode.keym.RusBig) { s = "Х"; }
                else if (curMode == mode.keym.Eng) { s = "["; }
                else if (curMode == mode.keym.EngBig) { s = "{"; }
                return s;
            }
        }
        private string b12b
        {
            get
            {
                string s = "ъ";
                if (curMode == mode.keym.RusBig) { s = "Ъ"; }
                else if (curMode == mode.keym.Eng) { s = "]"; }
                else if (curMode == mode.keym.EngBig) { s = "}"; }
                return s;
            }
        }

        //===================третий ряд клавиш
        private void bTab()
        {
            if (curMode == mode.keym.RusBig) { curMode = mode.keym.Rus; }
            else if (curMode == mode.keym.Eng) { curMode = mode.keym.EngBig; }
            else if (curMode == mode.keym.EngBig) { curMode = mode.keym.Eng; }
            else if (curMode == mode.keym.Rus) { curMode = mode.keym.RusBig; }
        }
        private string b3_1
        {
            get
            {
                string s = "ф";
                if (curMode == mode.keym.RusBig) { s = "Ф"; }
                else if (curMode == mode.keym.Eng) { s = "a"; }
                else if (curMode == mode.keym.EngBig) { s = "A"; }
                return s;
            }
        }
        private string b3_2
        {
            get
            {
                string s = "ы";
                if (curMode == mode.keym.RusBig) { s = "Ы"; }
                else if (curMode == mode.keym.Eng) { s = "s"; }
                else if (curMode == mode.keym.EngBig) { s = "S"; }
                return s;
            }
        }
        private string b3_3
        {
            get
            {
                string s = "в";
                if (curMode == mode.keym.RusBig) { s = "В"; }
                else if (curMode == mode.keym.Eng) { s = "d"; }
                else if (curMode == mode.keym.EngBig) { s = "D"; }
                return s;
            }
        }
        private string b3_4
        {
            get
            {
                string s = "а";
                if (curMode == mode.keym.RusBig) { s = "А"; }
                else if (curMode == mode.keym.Eng) { s = "f"; }
                else if (curMode == mode.keym.EngBig) { s = "F"; }
                return s;
            }
        }
        private string b3_5
        {
            get
            {
                string s = "п";
                if (curMode == mode.keym.RusBig) { s = "П"; }
                else if (curMode == mode.keym.Eng) { s = "g"; }
                else if (curMode == mode.keym.EngBig) { s = "G"; }
                return s;
            }
        }
        private string b3_6
        {
            get
            {
                string s = "р";
                if (curMode == mode.keym.RusBig) { s = "Р"; }
                else if (curMode == mode.keym.Eng) { s = "h"; }
                else if (curMode == mode.keym.EngBig) { s = "H"; }
                return s;
            }
        }
        private string b3_7
        {
            get
            {
                string s = "о";
                if (curMode == mode.keym.RusBig) { s = "О"; }
                else if (curMode == mode.keym.Eng) { s = "j"; }
                else if (curMode == mode.keym.EngBig) { s = "J"; }
                return s;
            }
        }
        private string b3_8
        {
            get
            {
                string s = "л";
                if (curMode == mode.keym.RusBig) { s = "Л"; }
                else if (curMode == mode.keym.Eng) { s = "k"; }
                else if (curMode == mode.keym.EngBig) { s = "K"; }
                return s;
            }
        }
        private string b3_9
        {
            get
            {
                string s = "д";
                if (curMode == mode.keym.RusBig) { s = "Д"; }
                else if (curMode == mode.keym.Eng) { s = "l"; }
                else if (curMode == mode.keym.EngBig) { s = "L"; }
                return s;
            }
        }
        private string b3_10
        {
            get
            {
                string s = "ж";
                if (curMode == mode.keym.RusBig) { s = "Ж"; }
                else if (curMode == mode.keym.Eng) { s = ";"; }
                else if (curMode == mode.keym.EngBig) { s = ":"; }
                return s;
            }
        }
        private string b3_11
        {
            get
            {
                string s = "э";
                if (curMode == mode.keym.RusBig) { s = "Э"; }
                else if (curMode == mode.keym.Eng) { s = "'"; }
                else if (curMode == mode.keym.EngBig) { s = "'"; }
                return s;
            }
        }
        //================четв ряд клавиш
        private string b4_1
        {
            get
            {
                string s = "я";
                if (curMode == mode.keym.RusBig) { s = "Я"; }
                else if (curMode == mode.keym.Eng) { s = "z"; }
                else if (curMode == mode.keym.EngBig) { s = "Z"; }
                return s;
            }
        }
        private string b4_2
        {
            get
            {
                string s = "ч";
                if (curMode == mode.keym.RusBig) { s = "Ч"; }
                else if (curMode == mode.keym.Eng) { s = "x"; }
                else if (curMode == mode.keym.EngBig) { s = "X"; }
                return s;
            }
        }
        private string b4_3
        {
            get
            {
                string s = "с";
                if (curMode == mode.keym.RusBig) { s = "С"; }
                else if (curMode == mode.keym.Eng) { s = "c"; }
                else if (curMode == mode.keym.EngBig) { s = "C"; }
                return s;
            }
        }
        private string b4_4
        {
            get
            {
                string s = "м";
                if (curMode == mode.keym.RusBig) { s = "М"; }
                else if (curMode == mode.keym.Eng) { s = "v"; }
                else if (curMode == mode.keym.EngBig) { s = "V"; }
                return s;
            }
        }
        private string b4_5
        {
            get
            {
                string s = "и";
                if (curMode == mode.keym.RusBig) { s = "И"; }
                else if (curMode == mode.keym.Eng) { s = "b"; }
                else if (curMode == mode.keym.EngBig) { s = "B"; }
                return s;
            }
        }
        private string b4_6
        {
            get
            {
                string s = "Т";
                if (curMode == mode.keym.RusBig) { s = "Т"; }
                else if (curMode == mode.keym.Eng) { s = "n"; }
                else if (curMode == mode.keym.EngBig) { s = "N"; }
                return s;
            }
        }
        private string b4_7
        {
            get
            {
                string s = "ь";
                if (curMode == mode.keym.RusBig) { s = "Ь"; }
                else if (curMode == mode.keym.Eng) { s = "m"; }
                else if (curMode == mode.keym.EngBig) { s = "M"; }
                return s;
            }
        }
        private string b4_8
        {
            get
            {
                string s = "б";
                if (curMode == mode.keym.RusBig) { s = "Б"; }
                else if (curMode == mode.keym.Eng) { s = ","; }
                else if (curMode == mode.keym.EngBig) { s = "<"; }
                return s;
            }
        }
        private string b4_9
        {
            get
            {
                string s = "ю";
                if (curMode == mode.keym.RusBig) { s = "Ю"; }
                else if (curMode == mode.keym.Eng) { s = "."; }
                else if (curMode == mode.keym.EngBig) { s = ">"; }
                return s;
            }
        }
        private string b4_10
        {
            get
            {
                string s = ".";
                if (curMode == mode.keym.RusBig) { s = ","; }
                else if (curMode == mode.keym.Eng) { s = "/"; }
                else if (curMode == mode.keym.EngBig) { s = "?"; }
                return s;
            }
        }
        private string b5_setLanguage
        {
            get
            {
                string s = "R";
                if (curMode == mode.keym.Eng || curMode == mode.keym.EngBig) { s = "E"; }
                else if (curMode == mode.keym.Rus || curMode == mode.keym.RusBig) { s = "R"; }
                return s;
            }
        }
        private string b5_setLevel
        {
            get
            {
                string s = "h";
                if (curMode == mode.keym.RusBig || curMode == mode.keym.EngBig) { s = "h"; }
                else if (curMode == mode.keym.Rus || curMode == mode.keym.Eng) { s = "i"; }
                return s;
            }
        }



        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            setFontMM(true);
        }

        private void toolStripButton3_Click(object sender, EventArgs e)
        {
            setFontMM(false );
        }
        void setFontMM(bool TruePlus_FalseMinus)
        {
            float fl = dataGridView1.DefaultCellStyle.Font.Size;

            if (TruePlus_FalseMinus) { fl = fl + 2; } else {if(fl>2)  fl = fl - 2; }
            q.put(param.size_font_in_GRID_find_32, Convert.ToInt32(fl));
            dataGridView1.DefaultCellStyle.Font = new Font("Courier New", fl);
        }
        private void setLanguage()
        {
            if (curMode == mode.keym.Eng)
            {
                curMode = mode.keym.Rus;
            }
            else if (curMode == mode.keym.Rus)
            {
                curMode = mode.keym.Eng;
            }
            else if (curMode == mode.keym.EngBig)
            {
                curMode = mode.keym.RusBig;
            }
            else if (curMode == mode.keym.RusBig)
            {
                curMode = mode.keym.EngBig;
            }

            setTxtButton();
        }
        private void setLevelHL()
        {
            if (curMode == mode.keym.EngBig)
            {
                curMode = mode.keym.Eng;
            }
            else if (curMode == mode.keym.RusBig)
            {
                curMode = mode.keym.Rus;
            }
            else if (curMode == mode.keym.Rus)
            {
                curMode = mode.keym.RusBig;
            }
            else if (curMode == mode.keym.Eng)
            {
                curMode = mode.keym.EngBig;
            }

            setTxtButton();
        }
        private void setTxtButton()
        {
            button1.Text = b00;
            button2.Text = b1;
            button3.Text = b2;
            button4.Text = b3;
            button5.Text = b4;
            button10.Text = b5;
            button9.Text = b6;
            button8.Text = b7;
            button7.Text = b8;
            button6.Text = b9;
            button12.Text = b0;
            button14.Text = b10;
            button13.Text = b11;

            button26.Text = b1b;
            button25.Text = b2b;
            button24.Text = b3b;
            button23.Text = b4b;
            button22.Text = b5b;
            button21.Text = b6b;
            button19.Text = b7b;
            button18.Text = b8b;
            button17.Text = b9b;
            button16.Text = b10b;
            button15.Text = b11b;
            button63.Text = b12b;

            button40.Text = b3_1;
            button39.Text = b3_2;
            button38.Text = b3_3;
            button37.Text = b3_4;
            button36.Text = b3_5;
            button35.Text = b3_6;
            button34.Text = b3_7;
            button33.Text = b3_8;
            button32.Text = b3_9;
            button31.Text = b3_10;
            button30.Text = b3_11;

            button52.Text = b4_1;
            button51.Text = b4_2;
            button50.Text = b4_3;
            button49.Text = b4_4;
            button48.Text = b4_5;
            button47.Text = b4_6;
            button46.Text = b4_7;
            button45.Text = b4_8;
            button44.Text = b4_9;
            button43.Text = b4_10;

            button59.Text = b5_setLanguage;
            button62.Text = b5_setLevel;
        }
        private void toolStripButton8_Click(object sender, EventArgs e)
        {
            IsOK = false; this.Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            putTxt(b00);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            putTxt(b1);
        }

        private void button3_Click(object sender, EventArgs e)
        {
            putTxt(b2);
        }

        private void button4_Click(object sender, EventArgs e)
        {
            putTxt(b3);
        }

        private void button5_Click(object sender, EventArgs e)
        {
            putTxt(b4);
        }

        private void button10_Click(object sender, EventArgs e)
        {
            putTxt(b5);
        }

        private void button9_Click(object sender, EventArgs e)
        {
            putTxt(b6);
        }

        private void button8_Click(object sender, EventArgs e)
        {
            putTxt(b7);
        }

        private void button7_Click(object sender, EventArgs e)
        {
            putTxt(b8);
        }

        private void button6_Click(object sender, EventArgs e)
        {
            putTxt(b9);
        }

        private void button12_Click(object sender, EventArgs e)
        {
            putTxt(b0);
        }

        private void button14_Click(object sender, EventArgs e)
        {
            putTxt(b10);
        }

        private void button13_Click(object sender, EventArgs e)
        {
            putTxt(b11);
        }

        private void button11_Click(object sender, EventArgs e)
        {
            backTxt();
        }








        //--2
        private void button28_Click(object sender, EventArgs e)
        {
            putTxt(b111);
        }

        private void button26_Click(object sender, EventArgs e)
        {
            putTxt(b1b);
        }

        private void button25_Click(object sender, EventArgs e)
        {
            putTxt(b2b);
        }

        private void button24_Click(object sender, EventArgs e)
        {
            putTxt(b3b);
        }

        private void button23_Click(object sender, EventArgs e)
        {
            putTxt(b4b);
        }

        private void button22_Click(object sender, EventArgs e)
        {
            putTxt(b5b);
        }

        private void button21_Click(object sender, EventArgs e)
        {
            putTxt(b6b);
        }

        private void button20_Click(object sender, EventArgs e)
        {
            putTxt(b7b);
        }

        private void button19_Click(object sender, EventArgs e)
        {
            putTxt(b8b);
        }

        private void button18_Click(object sender, EventArgs e)
        {
            putTxt(b9b);
        }

        private void button17_Click(object sender, EventArgs e)
        {
            putTxt(b10b);
        }

        private void button16_Click(object sender, EventArgs e)
        {
            putTxt(b11b);
        }

        private void button15_Click(object sender, EventArgs e)
        {
            putTxt(b12b);
        }

        private void button63_Click(object sender, EventArgs e)
        {
           
        }




        //--3
        private void button41_Click(object sender, EventArgs e)
        {
            bTab();
        }

        private void button40_Click(object sender, EventArgs e)
        {
            putTxt(b3_1);
        }

        private void button39_Click(object sender, EventArgs e)
        {
            putTxt(b3_2);
        }

        private void button38_Click(object sender, EventArgs e)
        {
            putTxt(b3_3);
        }

        private void button37_Click(object sender, EventArgs e)
        {
            putTxt(b3_4);
        }

        private void button36_Click(object sender, EventArgs e)
        {
            putTxt(b3_5);
        }

        private void button35_Click(object sender, EventArgs e)
        {
            putTxt(b3_6);
        }

        private void button34_Click(object sender, EventArgs e)
        {
            putTxt(b3_7);
        }

        private void button33_Click(object sender, EventArgs e)
        {
            putTxt(b3_8);
        }

        private void button32_Click(object sender, EventArgs e)
        {
            putTxt(b3_9);
        }

        private void button31_Click(object sender, EventArgs e)
        {
            putTxt(b3_10);
        }

        private void button30_Click(object sender, EventArgs e)
        {
            putTxt(b3_11);
        }

        private void button29_Click(object sender, EventArgs e)
        {
            refreshGridWithFilter("а");
        }


        //--4
        private void button62_Click(object sender, EventArgs e)
        {
            setLevelHL();
        }

        private void button53_Click(object sender, EventArgs e)
        {

        }

        private void button52_Click(object sender, EventArgs e)
        {
            putTxt(b4_1);
        }

        private void button51_Click(object sender, EventArgs e)
        {
            putTxt(b4_2);
        }

        private void button50_Click(object sender, EventArgs e)
        {
            putTxt(b4_3);
        }

        private void button49_Click(object sender, EventArgs e)
        {
            putTxt(b4_4);
        }

        private void button48_Click(object sender, EventArgs e)
        {
            putTxt(b4_5);
        }

        private void button47_Click(object sender, EventArgs e)
        {
            putTxt(b4_6);
        }

        private void button46_Click(object sender, EventArgs e)
        {
            putTxt(b4_7);
        }

        private void button45_Click(object sender, EventArgs e)
        {
            putTxt(b4_8);
        }

        private void button44_Click(object sender, EventArgs e)
        {
            putTxt(b4_9);
        }

        private void button43_Click(object sender, EventArgs e)
        {
            putTxt(b4_10);
        }

        private void button66_Click(object sender, EventArgs e)
        {

        }

        private void button67_Click(object sender, EventArgs e)
        {
            IsEnter = false;
            valueEnter = "";
            this.Close();
        }


        //--5
        private void button59_Click(object sender, EventArgs e)
        {
            setLanguage();
        }

        private void button55_Click(object sender, EventArgs e)
        {

        }

        private void button54_Click(object sender, EventArgs e)
        {

        }

        private void button56_Click(object sender, EventArgs e)
        {
            putTxt(" ");
        }

        private void button65_Click(object sender, EventArgs e)
        {
            putTxt(b_kav);
        }

        private void button57_Click(object sender, EventArgs e)
        {

        }

        private void button58_Click(object sender, EventArgs e)
        {

        }

        private void button61_Click(object sender, EventArgs e)
        {
            putTxt(",");
        }

        private void button27_Click(object sender, EventArgs e)
        {
            putTxt(":");
        }

        private void button64_Click(object sender, EventArgs e)
        {
            putTxt(".");
        }

        private void button60_Click(object sender, EventArgs e)
        {

        }


        private string b_kav
        {
            get
            {
                string s = "`";

                return s;
            }
        }

        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            IsEnter = false; this.Close();
            //readControl2();// IsOK = true; this.Close();
        }

        //private void readControl()
        //{
        //    int ic = this.Controls.Count;
        //    string s = ""; int i = 0;
        //    foreach (Control c in this.Controls)
        //    {
        //        if (i == 0) { s = c.Name; } else { s = string.Concat(s,"; ", c.Name); } i++;
        //    }
        //    h.m(s);
        //}
        private bool int_to_bool(int ii) { bool b = false; if (ii == 1) { b = true; } return b; }
        private void readControl2()
        {
           // string[] sa = qg.tk_array_string(ETALON.ENUMS.PLP_FormGridSelect.names_control_6);
            int[] av = qg.tk_array_int(ETALON.ENUMS.PLP_FormGridSelect.visible_controls_7);
            toolStripTextBox1.Visible  = int_to_bool(av[0]);
            toolStripButton1.Visible = int_to_bool(av[1]);
            toolStripButton3.Visible = int_to_bool(av[2]);
            toolStripButton2.Visible = int_to_bool(av[3]);
            toolStripButton8.Visible = int_to_bool(av[4]);
            splitContainer1.Panel1Collapsed = int_to_bool(av[5]);
            splitContainer1.Panel2Collapsed = int_to_bool(av[6]);

        }

        private void toolStripButton4_Click(object sender, EventArgs e)
        {
            IsEnter = true; this.Close();
        }
        
        

    }
}
